﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Myotragus.Store.Models.CultureSelection>" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Myotragus.Store.Models" %>

<% 
  var model = Model ?? new CultureSelection() ;
  
  if (model.RouteValues == null)
    model.RouteValues = new Dictionary<string, object>();
  
  var action = model.Action ?? "ChangeCulture";
  var controller = model.Controller ?? "Account";
  var cultureParameter = model.CultureParameterName ?? "Culture";

  var routeValues = new RouteValueDictionary(model.RouteValues);
%>
  <div class="culture-box"> 
<%
  foreach (var cul in CultureHelper.Cultures.Select(c => CultureInfo.GetCultureInfo(c)))
  {
    routeValues[cultureParameter] = cul.Name;
%>
  <div class="culture-link">
  <%= Html.ActionLink(cul.NativeName, action, controller, routeValues, null) %>
  </div>
<% 
  } 
%>
  </div>